﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using SosData;

namespace SosForms
{
    public partial class FormBuscar : FormBase
    {
        #region " Constructores "
        /// <summary>
        /// Constructor
        /// </summary>
        public FormBuscar()
        {
            InitializeComponent();
        }

        Type _entidad = null;
        public FormBuscar(Type entidad)
        {
            InitializeComponent();
            _entidad = entidad;

            var listCampos = SosBL.DataBL.GetProperties(entidad);
            this.cmbCampos.DataSource = listCampos;
            this.cmbCampos.Refresh();
        }

        /// <summary>
        /// Filtrar datos
        /// </summary>
        private void Filtrar()
        {
           // var resultados = SosBL.DataBL.Filter(_entidad, this.cmbCampos.Text, this.txtCriteria.Text, this.cmbOperadores.Text);
           // bindingSource.DataSource = resultados.Cast<Usuario>();

            dataGridView1.EndEdit();
            bindingSource.EndEdit();
            dataGridView1.RefreshEdit();

            dataGridView1.DataSource = bindingSource;

            


            dataGridView1.Refresh();
            dataGridView1.Parent.Refresh();

            this.Refresh();

            romListBox1.DataSource = bindingSource;
            romListBox1.DisplayMember = "Name";
            romListBox1.ValueMember = "Id";

        }

        #endregion

        /// <summary>
        /// Filtrar
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void butBuscar_Click(object sender, EventArgs e)
        {
            Filtrar();
        }



    }
}
